package mk.finki.chemistry.dice;

import org.jgap.Configuration;
import org.jgap.DefaultFitnessEvaluator;
import org.jgap.InvalidConfigurationException;
import org.jgap.event.EventManager;
import org.jgap.impl.BestChromosomesSelector;
import org.jgap.impl.ChromosomePool;
import org.jgap.impl.CrossoverOperator;
import org.jgap.impl.MutationOperator;
import org.jgap.impl.StockRandomGenerator;

public class DiceConfiguration extends Configuration {

	private static final long serialVersionUID = 5824338469013365396L;

	public DiceConfiguration() {
		super("", "");
		try {
			setBreeder(new DiceBreeder());
			setRandomGenerator(new StockRandomGenerator());
			setEventManager(new EventManager());
			BestChromosomesSelector bestChromsSelector = new BestChromosomesSelector(this, 0.90d);
			bestChromsSelector.setDoubletteChromosomesAllowed(true);
			addNaturalSelector(bestChromsSelector, false);
			setMinimumPopSizePercent(0);
			//
			setSelectFromPrevGen(1.0d);
			setKeepPopulationSizeConstant(true);
			setFitnessEvaluator(new DefaultFitnessEvaluator());
			setChromosomePool(new ChromosomePool());
			addGeneticOperator(new CrossoverOperator(this, 0.35d));
			addGeneticOperator(new MutationOperator(this, 12));
		} catch (InvalidConfigurationException e) {
			throw new RuntimeException("Fatal error: DefaultConfiguration class could not use its "
					+ "own stock configuration values. This should never happen. "
					+ "Please report this as a bug to the JGAP team.");
		}
	}
}
